package com.c.ctgproject.ui.sell.material

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.utils.awaitSync
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.utils.launch
import com.c.ctgproject.utils.userToken

class MaterialSellListViewModel : BaseViewModel() {
    private val mList = MutableLiveData<String>()
    val list: LiveData<String> get() = mList

    fun getList(page: Int, size: Int) {
        launch({
            mList.value = ApiMethods.getApiService().getMaterialSellList(userToken, page, size).awaitSync()
        }, {
            mError.value=it.message.handlerNull()
        })
    }
}